< previous page page_302 next page >

Page 302
z0322-01.gif
Figure 10.25
Depth one, two, and three Peano curves.
e10a6a0a59f035e870d90cca05b85fce.gif
' Draw a Peano curve.
Private Sub Peano(ByVal depth As Integer, _
    ByVal dx As Single, ByVal dy As Single)
Dim dx3 As Single
Dim dy3 As Single

    If depth > 0 Then
        dx3 = dx / 3
        dy3 = dy / 3
        Peano depth - 1, dx3, dy3
        Peano depth - 1, dy3, dx3
        Peano depth - 1, dx3, dy3
        Peano depth - 1, -dy3, -dx3
        Peano depth - 1, -dx3, -dy3
        Peano depth - 1, -dy3, -dx3
        Peano depth - 1, dx3, dy3
        Peano depth - 1, dy3, dx3
        Peano depth - 1, dx3, dy3
    Else
        picCanvas.Line -Step(dx, dy)
    End If
End Sub
Gaskets
You can think of a fractal gasket as a geometric shape with some holes cut in it. The gasket shown in Figure 10.26 is called the Sierpinski gasket. The simplest way to create a Sierpinski gasket is to draw a large filled triangle. Break the triangle into four smaller triangles and erase the middle one. Then recursively call a subroutine to erase the middle triangles from the three remaining triangles.
The following source code uses this method to draw Sierpinski gaskets.
e10a6a0a59f035e870d90cca05b85fce.gif
Private Type POINTAPI
    X As Long

 
< previous page page_302 next page >